---
title: Maven
layout: page
pageOrder: 6
section: 'Where'
subsection: true
sitemap:
  priority: 0.6
  changefreq: 'monthly'
  lastmod: 2019-11-10T08:00:00+01:00
---

<h2>Maven Central &nbsp;&nbsp;<a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver"><img src="https://camo.githubusercontent.com/e81e59784109e88f76e25361cd6b4da7a5a18947/68747470733a2f2f6d6176656e2d6261646765732e6865726f6b756170702e636f6d2f6d6176656e2d63656e7472616c2f6f72672e6d6f636b2d7365727665722f6d6f636b7365727665722d6e657474792f62616467652e7376673f7374796c653d666c6174" alt="mockserver" data-canonical-src="https://maven-badges.herokuapp.com/maven-central/org.mock-server/mockserver-netty/badge.svg?style=flat" style="max-width:100%;"></a>
</h2>

<p>Maven Central contains the following released MockServer artifacts:</p>

<ul>
	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-netty">mockserver-netty</a> - a web server for mocking and proxying using Netty

        <p>Add to a maven build pom.xml as follows:</p>

<pre><code class="code xml">&lt;<span class="element">dependencies</span>&gt;
    ...
    &lt;<span class="element">dependency</span>&gt;
	    &lt;<span class="element">groupId</span>&gt;<span class="element_value">org.mock-server</span>&lt;/<span class="element">groupId</span>&gt;
	    &lt;<span class="element">artifactId</span>&gt;<span class="element_value">mockserver-netty</span>&lt;/<span class="element">artifactId</span>&gt;
	    &lt;<span class="element">version</span>&gt;<span class="element_value">RELEASE</span>&lt;/<span class="element">version</span>&gt;
    &lt;/<span class="element">dependency</span>&gt;
    ...
&lt;<span class="element">dependencies</span>&gt;</code></pre>

        <p>Add to a gradle build build.gradle as follows:</p>

<pre><code class="code"><span class="final">dependencies</span> {
    ...
    <span class="final">testImplementation</span>(<span class="string_literal">"org.mock-server:mockserver-netty:5.11.2"</span>)
    ...
}</code></pre></li>

	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-netty">mockserver-netty:jar-with-dependencies</a> - as above using Netty that includes all dependencies are bundled into the jar file, this artifact
		<a href="https://search.maven.org/remotecontent?filepath=org/mock-server/mockserver-netty/5.11.2/mockserver-netty-5.11.2-jar-with-dependencies.jar">can be downloaded</a>.
	</li>

	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-war">mockserver-war</a> - a deployable WAR for mocking that can be deployed to any JEE web server, this artifact
		<a href="https://search.maven.org/remotecontent?filepath=org/mock-server/mockserver-war/5.11.2/mockserver-war-5.11.2.war">can be downloaded</a>.
	</li>

	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-proxy-war">mockserver-proxy-war</a> - a deployable WAR for proxying that can be deployed to any JEE web server, this artifact
		<a href="https://search.maven.org/remotecontent?filepath=org/mock-server/mockserver-proxy-war/5.11.2/mockserver-proxy-war-5.11.2.war">can be downloaded</a>.
	</li>

	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-maven-plugin">mockserver-maven-plugin</a> - a set of maven plugins to start, stop and fork MockServer using maven

    <p>Add to a maven build pom.xml as follows:</p>

<pre><code class="code xml">&lt;<span class="element">plugin</span>&gt;
    &lt;<span class="element">groupId</span>&gt;<span class="element_value">org.mock-server</span>&lt;/<span class="element">groupId</span>&gt;
    &lt;<span class="element">artifactId</span>&gt;<span class="element_value">mockserver-maven-plugin</span>&lt;/<span class="element">artifactId</span>&gt;
    &lt;<span class="element">version</span>&gt;<span class="element_value">RELEASE</span>&lt;/<span class="element">version</span>&gt;
    &lt;<span class="element">configuration</span>&gt;
        &lt;<span class="element">serverPort</span>&gt;<span class="element_value">1080</span>&lt;/<span class="element">serverPort</span>&gt;
        &lt;<span class="element">pipeLogToConsole</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">pipeLogToConsole</span>&gt;
&lt;/<span class="element">plugin</span>&gt;</code></pre>

	<li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-client-java">mockserver-client-java</a> - a Java client to communicate with both the server and the proxy

    <p>Add to a maven build pom.xml as follows:</p>

<pre><code class="code xml">&lt;<span class="element">dependency</span>&gt;
	&lt;<span class="element">groupId</span>&gt;<span class="element_value">org.mock-server</span>&lt;/<span class="element">groupId</span>&gt;
	&lt;<span class="element">artifactId</span>&gt;<span class="element_value">mockserver-client-java</span>&lt;/<span class="element">artifactId</span>&gt;
	&lt;<span class="element">version</span>&gt;<span class="element_value">RELEASE</span>&lt;/<span class="element">version</span>&gt;
&lt;/<span class="element">dependency</span>&gt;</code></pre>

    <p>Add to a gradle build build.gradle as follows:</p>

<pre><code class="code"><span class="final">dependencies</span> {
    ...
    <span class="final">testImplementation</span>(<span class="string_literal">"org.mock-server:mockserver-client-java:5.11.2"</span>)
    ...
}</code></pre></li>

    <li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-client-java">mockserver-junit-rule</a> - a <a href="/mock_server/running_mock_server.html#junit_rule">Junit 4 @Rule</a> that starts MockServer (<strong>for both mocking and proxying</strong>) on a free port before the any test runs and stops MockServer after all tests have completed.</li>

    <li><a href="https://search.maven.org/#search%7Cga%7C1%7Cmockserver-client-java">mockserver-junit-jupiter</a> - a <a href="/mock_server/running_mock_server.html#junit_rule">Junit 5 Test Extension</a> that starts MockServer (<strong>for both mocking and proxying</strong>) on a free port before the any test runs and stops MockServer after all tests have completed.</li>
</ul>

<a id="sonatype_snapshot" class="anchor" href="#sonatype_snapshot">&nbsp;</a>

<h2>Sonatype SNAPSHOT</h2>

<p>The latest SNAPSHOT version can be found at <a href="https://oss.sonatype.org/index.html#nexus-search;gav~org.mock-server~~~~">Sonatype</a></p>

<h3>Maven</h3>

<p>To use the SNAPSHOT version in a maven project you need to configure your maven <strong>settings.xml</strong> or your <strong>pom.xml</strong> to include the Sonatype SNAPSHOT repository as follows:</p>

<pre><code class="code xml">&lt;<span class="element">profile</span>&gt;
    &lt;<span class="element">id</span>&gt;<span class="element_value">sonatype</span>&lt;/<span class="element">id</span>&gt;
    &lt;<span class="element">activation</span>&gt;
        &lt;<span class="element">activeByDefault</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">activeByDefault</span>&gt;
    &lt;/<span class="element">activation</span>&gt;
    &lt;<span class="element">repositories</span>&gt;
        &lt;<span class="element">repository</span>&gt;
            &lt;<span class="element">id</span>&gt;<span class="element_value">sonatype-nexus-snapshots</span>&lt;/<span class="element">id</span>&gt;
            &lt;<span class="element">name</span>&gt;<span class="element_value">sonatype-nexus-snapshots</span>&lt;/<span class="element">name</span>&gt;
            &lt;<span class="element">url</span>&gt;<span class="element_value">https://oss.sonatype.org/content/repositories/snapshots</span>&lt;/<span class="element">url</span>&gt;
            &lt;<span class="element">layout</span>&gt;<span class="element_value">default</span>&lt;/<span class="element">layout</span>&gt;
            &lt;<span class="element">releases</span>&gt;
                &lt;<span class="element">enabled</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">enabled</span>&gt;
            &lt;/<span class="element">releases</span>&gt;
            &lt;<span class="element">snapshots</span>&gt;
                &lt;<span class="element">enabled</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">enabled</span>&gt;
            &lt;/<span class="element">snapshots</span>&gt;
        &lt;/<span class="element">repository</span>&gt;
    &lt;/<span class="element">repositories</span>&gt;
    &lt;<span class="element">pluginRepositories</span>&gt;
        &lt;<span class="element">pluginRepository</span>&gt;
            &lt;<span class="element">id</span>&gt;<span class="element_value">sonatype-nexus-snapshots</span>&lt;/<span class="element">id</span>&gt;
            &lt;<span class="element">name</span>&gt;<span class="element_value">sonatype-nexus-snapshots</span>&lt;/<span class="element">name</span>&gt;
            &lt;<span class="element">url</span>&gt;<span class="element_value">https://oss.sonatype.org/content/repositories/snapshots</span>&lt;/<span class="element">url</span>&gt;
            &lt;<span class="element">layout</span>&gt;<span class="element_value">default</span>&lt;/<span class="element">layout</span>&gt;
            &lt;<span class="element">releases</span>&gt;
                &lt;<span class="element">enabled</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">enabled</span>&gt;
            &lt;/<span class="element">releases</span>&gt;
            &lt;<span class="element">snapshots</span>&gt;
                &lt;<span class="element">enabled</span>&gt;<span class="element_value">true</span>&lt;/<span class="element">enabled</span>&gt;
            &lt;/<span class="element">snapshots</span>&gt;
        &lt;/<span class="element">pluginRepository</span>&gt;
    &lt;/<span class="element">pluginRepositories</span>&gt;
&lt;/<span class="element">profile</span>&gt;</code></pre>

<p><strong>Note:</strong> typically it is best practice to configure the <strong>~/.m2/settings.xml</strong> file instead of the <strong>settings.xml</strong> file located inside the <strong>conf</strong> directory in the maven installation directory (i.e. <strong>$M2_HOME</strong>). This is because the
	<strong>~/.m2/settings.xml</strong> file will be consistent between maven version upgrades and any changes to this file will only affect a single user.</p>

<p>Once the Sonatype SNAPSHOT repository has been added, as above, the latest SNAPSHOT build can referenced.</p><p>For example add a dependency on the latest SNAPSHOT build for <strong>mockserver-netty</strong>, as follows:</p>

<pre><code class="code xml">&lt;<span class="element">dependency</span>&gt;
	&lt;<span class="element">groupId</span>&gt;<span class="element_value">org.mock-server</span>&lt;/<span class="element">groupId</span>&gt;
	&lt;<span class="element">artifactId</span>&gt;<span class="element_value">mockserver-netty</span>&lt;/<span class="element">artifactId</span>&gt;
	&lt;<span class="element">version</span>&gt;<span class="element_value">SNAPSHOT</span>&lt;/<span class="element">version</span>&gt;
&lt;/<span class="element">dependency</span>&gt;</code></pre>

<h3>Gradle</h3>

<p>To use the SNAPSHOT version in a gralde project you need to add the correct repository into the project as follows:</p>

<pre><code class="code"><span class="final">repositories</span> {
    ...
    <span class="final">maven</span> { <span class="final">url</span> <span class="string_literal">"https://oss.sonatype.org/content/repositories/snapshots"</span> }
    ...
}</code></pre>

<p>Once the Sonatype SNAPSHOT repository has been added, the latest SNAPSHOT build can referenced, as follows:</p>

<pre><code class="code"><span class="final">dependencies</span> {
    ...
    <span class="final">testImplementation</span>(<span class="string_literal">"org.mock-server:mockserver-netty:5.11.2-SNAPSHOT"</span>)
    ...
}</code></pre>